package com.wei.dubbo.demo.basic.api.consumer;

import com.wei.dubbo.demo.init.common.service.GreetingsService;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;

public class BasicApiConsumerApplication {
    public static void main(String[] args) throws Exception {
        ReferenceConfig<GreetingsService> greetingsServiceReferenceConfig = new ReferenceConfig<>();
        greetingsServiceReferenceConfig.setInterface(GreetingsService.class);

        ApplicationConfig applicationConfig = new ApplicationConfig();
        applicationConfig.setName("basic-api-consumer-demo");
        applicationConfig.setQosPort(22223);
        DubboBootstrap.getInstance()
                .application(applicationConfig)
                .registry(new RegistryConfig("zookeeper://127.0.0.1:2181"))
                .reference(greetingsServiceReferenceConfig);

        GreetingsService service = greetingsServiceReferenceConfig.get();
        String message = service.sayHi("dubbo");
        System.out.println("=========== result: " + message);

    }
}
